<template>
  <!-- 封装一个全局国际化组件 -->
  <el-dropdown>
    <div>
      <svg-icon style="font-size: 20px; color: #fff;" class="icon" icon-class="language" />
    </div>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item :disabled="$i18n.locale==='zh'" @click.native="changeLang('zh')">中文</el-dropdown-item>
        <el-dropdown-item :disabled="$i18n.locale==='en'" @click.native="changeLang('en')">英文</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script>
import jsCookie from 'js-cookie'
export default {
  name: 'Lang',
  methods: {
    changeLang(str) {
      this.$i18n.locale = str
      jsCookie.set('lang', str)
      /* this.$router.go(0)  （）里面为 负数就上一页 正数就下一页  0就刷新 */
      this.$router.go(0)
    }
  }

}
</script>

<style>

</style>
